package code._10string._04sort.demo2;

public class Student implements Comparable<Student>{
    String name;
    int age;
    int score;

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    //综合排序、按年龄升序、相同则按分数降序
    @Override
    public int compareTo(Student o) {
        if(this.age==o.age){
            return o.score-this.score;
        }
        return this.age-o.age;
    }
}
